/**
    入驻小区
**/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            chainInoutOrderManageInfo: {
                chainInoutOrders: [],
                states: [],
                total: 0,
                records: 1,
                moreCondition: false,
                orderId: '',
                conditions: {
                    orderType: '',
                    inOrderId: '',

                }
            }
        },
        _initMethod: function () {
            $that._listChainInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
        
            vc.on('chainInoutOrderManage', 'listChainInoutOrder', function (_param) {
                $that._listChainInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listChainInoutOrders(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listChainInoutOrders: function (_page, _rows) {

                $that.chainInoutOrderManageInfo.conditions.page = _page;
                $that.chainInoutOrderManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.chainInoutOrderManageInfo.conditions
                };

                //发送get请求
                vc.http.apiGet('chainInoutOrder.listChainInoutOrder',
                    param,
                    function (json, res) {
                        var _chainInoutOrderManageInfo = JSON.parse(json);
                        $that.chainInoutOrderManageInfo.total = _chainInoutOrderManageInfo.total;
                        $that.chainInoutOrderManageInfo.records = _chainInoutOrderManageInfo.records;
                        $that.chainInoutOrderManageInfo.chainInoutOrders = _chainInoutOrderManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.chainInoutOrderManageInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddChainInoutOrderModal: function () {
                vc.emit('addChainInoutOrder', 'openAddChainInoutOrderModal', {});
            },
            _openEditChainInoutOrderModel: function (_chainInoutOrder) {
                vc.emit('editChainInoutOrder', 'openEditChainInoutOrderModal', _chainInoutOrder);
            },
            _openDeleteChainInoutOrderModel: function (_chainInoutOrder) {
                vc.emit('deleteChainInoutOrder', 'openDeleteChainInoutOrderModal', _chainInoutOrder);
            },
            _queryChainInoutOrderMethod: function () {
                $that._listChainInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition: function () {
                if ($that.chainInoutOrderManageInfo.moreCondition) {
                    $that.chainInoutOrderManageInfo.moreCondition = false;
                } else {
                    $that.chainInoutOrderManageInfo.moreCondition = true;
                }
            }


        }
    });
})(window.vc);
